package cn.bdqn.controller.reportForms;

import cn.bdqn.dao.reportForms.OrderRegisterReportFormsMapper;
import cn.bdqn.pojo.reportForms.OrderRegisterReportForms;
import cn.bdqn.utils.Json;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Objects;

@RestController
@RequestMapping("/api/orderForms")
public class OrderReportFormsController {

    @Autowired
    private OrderRegisterReportFormsMapper orderRegisterReportFormsMapper;

    @GetMapping("/onMonth")
    public Json getOrderRegisterReportFormsOnMonth(){
        List<OrderRegisterReportForms> orderRegisterReportFormsOnMonth =
                orderRegisterReportFormsMapper.getOrderRegisterReportFormsOnMonth();
        if (Objects.isNull(orderRegisterReportFormsOnMonth)){
            return Json.fall("查询失败");
        }
        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("list",orderRegisterReportFormsOnMonth);
        return Json.ok(objectObjectHashMap);
    }
    @GetMapping("/lastMonth")
    public Json getOrderRegisterReportFormsLastMonth(){
        List<OrderRegisterReportForms> orderRegisterReportFormsLastMonth =
                orderRegisterReportFormsMapper.getOrderRegisterReportFormsLastMonth();
        if(Objects.isNull(orderRegisterReportFormsLastMonth)){
            return Json.fall("查询失败");
        }
        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("list",orderRegisterReportFormsLastMonth);
        return Json.ok(objectObjectHashMap);
    }
}
